package yunwo.cn.yzstation.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;



import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Properties;

/**
 * 文件工具类
 * 
 */
public class FileUtil {

	private static final String TAG = "FileUtil";
	public static final String ICON_DIR = "icon";
	public static final String ROOT_DIR = "cloud";

	public static String readFile(File f) throws IOException {
		InputStream is = new FileInputStream(f);
		byte[] bs = new byte[is.available()];
		try {
			is.read(bs);
		} finally {
			try {
				is.close();
				is = null;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return new String(bs);
	}

	/**
	 * 根据文件绝对路径获取文件名
	 * 
	 * @param filePath
	 * @return
	 */
	public static String getFileName(String filePath) {
		if (StringUtil.isEmpty(filePath))
			return "";
		return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
	}

	/**
	 * 根据文件的绝对路径获取文件名但不包含扩展名
	 * 
	 * @param filePath
	 * @return
	 */
	public static String getFileNameNoFormat(String filePath) {
		if (StringUtil.isEmpty(filePath)) {
			return "";
		}
		int point = filePath.lastIndexOf('.');
		return filePath.substring(filePath.lastIndexOf(File.separator) + 1,
				point);
	}

	/**
	 * 获取文件扩展名
	 * 
	 * @param fileName
	 * @return
	 */
	public static String getFileFormat(String fileName) {
		if (StringUtil.isEmpty(fileName))
			return "";

		int point = fileName.lastIndexOf('.');
		return fileName.substring(point + 1);
	}

	/**
	 * 检查文件是否存在
	 * 
	 * @param name 文件名
	 * @return
	 */
	public static boolean checkFileExists(String name) {
		boolean status;
		if (!name.equals("")) {
			File path = Environment.getExternalStorageDirectory();
			File newPath = new File(path.toString() + name);
			status = newPath.exists();
		} else {
			status = false;
		}
		return status;
	}
	/**
	 * 检查文件是否存在
	 *
	 * @param path 完整路径
	 * @return
	 */
	public static boolean isFileExist(String path) {
		return new File(path).exists();
	}
	/**
	 * 删除指定的文件夹
	 * 
	 * @param filepath
	 * @throws IOException
	 */
	public static boolean deleteDir(String filepath) throws IOException {

		File f = new File(filepath);// 定义文件路径
		if (f.exists() && f.isDirectory()) {// 判断是文件还是目录
			if (f.listFiles().length == 0) {// 若目录下没有文件则直接删除
				f.delete();
			} else { // 若有则把文件放进数组，并判断是否有下级目录
				File delFile[] = f.listFiles();
				final int i = f.listFiles().length;
				for (int j = 0; j < i; j++) {
					if (delFile[j].isDirectory()) {
						deleteDir(delFile[j].getAbsolutePath());// 递归调用del方法并取得子目录路径
					}
					delFile[j].delete();
				}

				f.delete();
			}
		}
		return true;
	}

	/**
	 * 清空文件夹，但不删除该文件夹
	 * 
	 * @param dirPath
	 */
	public static boolean clearDir(String dirPath) {
		if (dirPath == null) {
			return false;
		}
		File f = new File(dirPath);// 定义文件路径
		File delFile[] = f.listFiles();
		final int i = f.listFiles().length;
		for (int j = 0; j < i; j++) {
			if (delFile[j].isDirectory()) {
				try {
					deleteDir(delFile[j].getAbsolutePath());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			delFile[j].delete();
		}
		return true;
	}

	/**
	 * 删除指定的文件
	 * 
	 * @param filePath
	 */
	public static void deleteFile(String filePath) throws IOException {
		if (filePath == null || StringUtil.isEmpty(filePath)) {
			return;
		}
		File file = new File(filePath);
		if (file.exists() && file.isFile()) {
			file.delete();
		}
	}

	/**
	 * 根据后缀名删除指定文件夹下特定后缀名的文件
	 * 
	 * @param dirPath
	 * @param suffix
	 */
	public static void deleteFileBySuffix(String dirPath, String suffix)
			throws IOException {

		File f = new File(dirPath);// 定义文件路径
		if (f.exists() && f.isDirectory()) {// 判断是文件还是目录
			if (f.listFiles().length != 0) {
				File delFile[] = f.listFiles();
				final int size = f.listFiles().length;
				for (int j = 0; j < size; j++) {
					if (delFile[j].getName().endsWith(suffix)) {
						delFile[j].delete();
					}
				}
			}
		}
	}

	/**
	 * 根据文件名删除指定文件夹下的文件
	 * 
	 * @param dirPath
	 * @param fileName
	 */
	public static void deleteFileByName(String dirPath, String fileName)
			throws Exception {

		File f = new File(dirPath);// 定义文件路径

		if (f.exists() && f.isDirectory()) {// 判断是文件还是目录
			if (f.listFiles().length != 0) {
				File delFile[] = f.listFiles();
				final int size = f.listFiles().length;
				for (int j = 0; j < size; j++) {
					if (delFile[j].getName().equals(fileName)) {
						delFile[j].delete();
					}
				}
			}
		}
	}

	/**
	 * 复制文件
	 * 
	 * @param sourcePath
	 * @param savePath
	 * @throws IOException
	 */
	public static void copyFile(String sourcePath, String savePath)
			throws IOException {

		if (sourcePath == null || StringUtil.isEmpty(sourcePath)) {
			throw new FileNotFoundException("原来目录不存在");
		}
		FileInputStream fis = new FileInputStream(new File(sourcePath));
		File saveFile = new File(savePath);
		File dir = saveFile.getParentFile();

		if (dir != null && !dir.exists()) {
			dir.mkdirs();
		}
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(saveFile);
			byte[] buffer = new byte[1024];
			int length = 0;

			while ((length = fis.read(buffer)) != -1) {
				fos.write(buffer);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (fos != null) {
				try {
					fos.close();
				} catch (Exception e2) {
					e2.printStackTrace();
				}
			}
		}
	}

	/**
	 * 从url中获取可写可读的连接 获取输入流： InputStream InputStream = conn.getInputStream();
	 * OutputStream outputStream = conn.getOutputStream();
	 * 用户记得关闭连接方法（conn.disconnect();）
	 * 
	 * @param url
	 * @param isOutput
	 *            是否获取输出流
	 * @return HttpURLConnection 可写可读的连接
	 * @throws IOException
	 */
	public static final HttpURLConnection getConnectionFromURl(String url,
															   boolean isOutput) throws IOException {

		HttpURLConnection conn = null;
		URL mUrl = new URL(url);
		conn = (HttpURLConnection) mUrl.openConnection();
		conn.setConnectTimeout(10 * 1000);
		conn.setUseCaches(false); // 不使用缓存

		conn.setDoInput(true);

		if (isOutput) {

			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("user-agent",
					"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
			conn.setRequestProperty("Charset", "UTF-8"); // 设置字符级编码

			conn.setDoOutput(true);
			conn.setRequestMethod("POST");
		}

		return conn;
	}

	/**
	 * 获取网络图片
	 * 
	 * @param url
	 * @return
	 * @throws Exception
	 */
	public static Bitmap getNetBitmap(String url) throws Exception {

		HttpURLConnection conn = null;
		Bitmap bitmap = null;
		int time = 0;
		final int retryTime = 3; // 重复连接次数
		do {
			try {
				conn = FileUtil.getConnectionFromURl(url, false);
				InputStream inStream = conn.getInputStream();
				bitmap = BitmapFactory.decodeStream(inStream);
				break;

			} catch (Exception e) {
				time++;
				if (time < retryTime) {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e1) {
					}
					continue;
				}
				// 发生网络异常
				e.printStackTrace();
				throw e;
			} finally {
				// 释放连接
				if (conn != null) {
					conn.disconnect();
					conn = null;
				}
			}
		} while (time < retryTime);

		return bitmap;
	}

	/**
	 * 上传文件
	 * 
	 * @param url
	 * @param filePath
	 * @return
	 * @throws Exception
	 */
	public static final String uploadFile(String url, String filePath)
			throws Exception {
		return uploadFile(url, filePath, null);
	}

	/**
	 * 上传文件
	 * 
	 * @param url
	 *            文件上传的url
	 * @param filePath
	 *            文件所在路径
	 * @param contentType
	 *            文件mine tpye类型
	 * @return 服务器返回的上传信息
	 * @throws Exception
	 */
	public static final String uploadFile(String url, String filePath,
										  String contentType) throws Exception {

		String response = null;
		File file = new File(filePath);

		HttpURLConnection conn = null;

		InputStream inStream = new FileInputStream(file);
		OutputStream outStream = null;

		byte[] buffer = new byte[1024];

		int time = 0;
		final int retryTime = 3; // 重复连接次数

		do {
			try {
				conn = FileUtil.getConnectionFromURl(url, true);
				// 设置文件的总长度
				conn.setRequestProperty("Content-Length",
						String.valueOf(file.length()));

				if (contentType != null) {

					// 设置文件类型
					// conn.setRequestProperty("Content-Type", contentType);
				}
				outStream = conn.getOutputStream();

				int len = -1;
				while ((len = inStream.read(buffer)) != -1) {
					outStream.write(buffer, 0, len);
				}
				response = conn.getResponseMessage();

				Log.d("uploadFile", "文件上传成功 ");

				break;

			} catch (Exception e) {
				time++;
				if (time < retryTime) {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e1) {
					}
					continue;
				}

				Log.d("uploadFile", "文件上传失败");

				// 发生网络异常
				e.printStackTrace();
				throw e;

			} finally {

				buffer = null;

				if (inStream != null) {
					try {
						inStream.close();
						inStream = null;
					} catch (Exception e2) {
					}
				}

				if (outStream != null) {
					try {
						outStream.close();
						outStream = null;
					} catch (Exception e2) {
					}
				}

				// 释放连接
				if (conn != null) {
					conn.disconnect();
					conn = null;
				}

			}

		} while (time < retryTime);

		return response;
	}

	/**
	 * 上传文件（文本文件，视频文件，图片，音频文件均可以）
	 * 
	 * 文件以字符串的形象封装在NameValuePair作为参数上传,需和服务端约定好参数名称
	 * 文件转字符串请参考FileUtil.writeFileToString()方法;
	 * 
	 * @param context
	 * @param url
	 * @param postParameters
	 * @return
	 * @throws Exception
	 */
/*	public static final String uploadFile(Context context, final String url,
										  final List<NameValuePair> postParameters) throws Exception {

		HttpClient httpClient = new DefaultHttpClient();

		HttpHost httpHost = new HttpHost(MyConstants.IP_ADDRESS,
				MyConstants.PORT, HttpHost.DEFAULT_SCHEME_NAME);

		HttpPost postRequest = new HttpPost(url);

		UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(
				postParameters, MyConstants.ENCODING); // 使用UTF-8进行编码
		postRequest.setEntity(formEntity);

		HttpResponse response = httpClient.execute(httpHost, postRequest);

		int statusCode = response.getStatusLine().getStatusCode();

		if (statusCode == HttpStatus.SC_OK) {

			HttpEntity entity = response.getEntity();
			String content = EntityUtils.toString(entity, MyConstants.ENCODING);

			// Log.v("HttpUtil uploadFile HttpResponse = ", content);

			return content;

		} else {

			LogUtil.d("HttpUtil uploadFile ", "上传文件失败");
			throw new Exception("上传文件失败");
		}
	}*/

	/**
	 * 下载文件
	 * 
	 * @param url
	 * @throws Exception
	 */
	public static void downloadFile(String url, String filePath)
			throws Exception {

		HttpURLConnection conn = null;
		InputStream inputStream = null;
		Bitmap bitmap;

		File file = new File(filePath);
		if (!file.getParentFile().exists()) {
			file.getParentFile().mkdirs();
		}

		FileOutputStream outputStream = new FileOutputStream(file);

		try {

			conn = getConnectionFromURl(url, false);
			if (conn.getResponseCode() == 404) {
				throw new Exception("404");
			}

			inputStream = conn.getInputStream();
			byte buffer[] = new byte[1024 * 5]; // 5Kb的缓存
			int readLength = 0;
			while ((readLength = inputStream.read(buffer)) > 0) {

				outputStream.write(buffer, 0, readLength);
			}

		} finally {
			if (conn != null) {
				conn.disconnect();
				conn = null;
			}
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				inputStream = null;
			}
			if (outputStream != null) {
				try {
					outputStream.flush();
					outputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				outputStream = null;
			}
		}
	}

	/**
	 * 下载文件
	 * 
	 * @param url
	 * @throws Exception
	 */
	public static void downloadAddressZipFile(String url, String filePath)
			throws Exception {

		HttpURLConnection conn = null;
		InputStream inputStream = null;

		File file = new File(filePath);
		if (!file.getParentFile().exists()) {
			file.getParentFile().mkdirs();
		}

		FileOutputStream outputStream = new FileOutputStream(file);

		try {

			int count = 0;

			do {
				conn = getConnectionFromURl(url, false);

				if (conn.getResponseCode() == 404) {

					count++;
					if (count < 5) {
						Thread.sleep(5000);
						continue;
					} else {
						throw new Exception("404");
					}

				} else {

					int zipSize = conn.getContentLength();

					if (zipSize == -1) {
						Log.d(TAG, "服务端zip文件zipSize = -1，5秒后进行第" + count
								+ "次重新连接");
						count++;
						Thread.sleep(5000);
					} else {
						break;
					}
				}

			} while (count < 5);

			inputStream = conn.getInputStream();
			byte buffer[] = new byte[1024 * 5]; // 5Kb的缓存
			int readLength = 0;
			while ((readLength = inputStream.read(buffer)) > 0) {

				outputStream.write(buffer, 0, readLength);
			}

		} finally {

			if (conn != null) {
				conn.disconnect();
				conn = null;
			}
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				inputStream = null;
			}
			if (outputStream != null) {
				try {
					outputStream.flush();
					outputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				outputStream = null;
			}

		}
	}

	/** 判断SD卡是否挂载 */
	public static boolean isSDCardAvailable() {
		if (Environment.MEDIA_MOUNTED.equals(Environment
				.getExternalStorageState())) {
			return true;
		} else {
			return false;
		}
	}

	/** 获取SD下的应用目录 */
	public static String getExternalStoragePath() {
		StringBuilder sb = new StringBuilder();
		sb.append(Environment.getExternalStorageDirectory().getAbsolutePath());
		sb.append(File.separator);
		sb.append(ROOT_DIR);
		sb.append(File.separator);
		return sb.toString();
	}
	public String getSDPath() {
		if (isSDCardAvailable()) {
			return Environment.getExternalStorageDirectory() + "/";
		}
		return null;
	}
	/** 获取应用的cache目录 */
	public static String getCachePath() {
		File f = UIUtils.getContext().getCacheDir();
		if (null == f) {
			return null;
		} else {
			return f.getAbsolutePath() + "/";
		}
	}

	/** 创建文件夹 */
	public static boolean createDirs(String dirPath) {
		Log.d(TAG, "dirPath:" + dirPath);
		File file = new File(dirPath);
		if (!file.exists() || !file.isDirectory()) {
			return file.mkdirs();
		}
		return true;
	}

	/** 获取icon目录 */
	public static String getIconDir() {
		return getDir(ICON_DIR);
	}

	/**
	 * 从url字符串获取文件名
	 * 
	 *
	 * @return 获取到的文件名
	 * */
	public static String getFileNameFromUrl(String url) {
		String result = "";
		Log.d(TAG, "url:" + url);
		String[] str = url.split("/");
		result = str[str.length - 1];
		return result;
	}

	/** 获取应用目录，当SD卡存在时，获取SD卡上的目录，当SD卡不存在时，获取应用的cache目录 */
	public static String getDir(String name) {
		StringBuilder sb = new StringBuilder();
		if (isSDCardAvailable()) {
			sb.append(getExternalStoragePath());
		} else {
			sb.append(getCachePath());
		}
		sb.append(name);
		sb.append(File.separator);
		String path = sb.toString();
		if (createDirs(path)) {
			return path;
		} else {
			return null;
		}
	}

	/**
	 * 把数据写入文件
	 * 
	 * @param is
	 *            数据流
	 * @param path
	 *            文件路径
	 * @param recreate
	 *            如果文件存在，是否需要删除重建
	 * @return 是否写入成功
	 */
	public static boolean writeFile(InputStream is, String path,
									boolean recreate) {
		boolean res = false;
		File f = new File(path);
		FileOutputStream fos = null;
		try {
			if (recreate && f.exists()) {
				f.delete();
			}
			if (!f.exists() && null != is) {
				File parentFile = new File(f.getParent());
				parentFile.mkdirs();
				int count = -1;
				byte[] buffer = new byte[1024];
				fos = new FileOutputStream(f);
				while ((count = is.read(buffer)) != -1) {
					fos.write(buffer, 0, count);
				}
				res = true;
			}
		} catch (Exception e) {
			Log.e(TAG, e.toString());
		} finally {
			IOUtils.close(fos);
			IOUtils.close(is);
		}
		return res;
	}

	/**
	 * 把字符串数据写入文件
	 * 
	 * @param content
	 *            需要写入的字符串
	 * @param path
	 *            文件路径名称
	 * @param append
	 *            是否以添加的模式写入
	 * @return 是否写入成功
	 */
	public static boolean writeFile(byte[] content, String path, boolean append) {
		boolean res = false;
		File f = new File(path);
		RandomAccessFile raf = null;
		try {
			if (f.exists()) {
				if (!append) {
					f.delete();
					f.createNewFile();
				}
			} else {
				f.createNewFile();
			}
			if (f.canWrite()) {
				raf = new RandomAccessFile(f, "rw");
				raf.seek(raf.length());
				raf.write(content);
				res = true;
			}
		} catch (Exception e) {
			Log.e(TAG, e.toString());
		} finally {
			IOUtils.close(raf);
		}
		return res;
	}

	/**
	 * 把字符串数据写入文件
	 * 
	 * @param content
	 *            需要写入的字符串
	 * @param path
	 *            文件路径名称
	 * @param append
	 *            是否以添加的模式写入
	 * @return 是否写入成功
	 */
	public static boolean writeFile(String content, String path, boolean append) {
		return writeFile(content.getBytes(), path, append);
	}

	/** 改名 */
	public static boolean copy(String src, String des, boolean delete) {
		File file = new File(src);
		if (!file.exists()) {
			return false;
		}
		File desFile = new File(des);
		FileInputStream in = null;
		FileOutputStream out = null;
		try {
			in = new FileInputStream(file);
			out = new FileOutputStream(desFile);
			byte[] buffer = new byte[1024];
			int count = -1;
			while ((count = in.read(buffer)) != -1) {
				out.write(buffer, 0, count);
				out.flush();
			}
		} catch (Exception e) {
			Log.e(TAG, e.toString());
			return false;
		} finally {
			IOUtils.close(in);
			IOUtils.close(out);
		}
		if (delete) {
			file.delete();
		}
		return true;
	}

	/** 根据值读取 */
	public static String readProperties(String filePath, String key,
										String defaultValue) {
		if (StringUtil.isEmpty(key) || StringUtil.isEmpty(filePath)) {
			return null;
		}
		String value = null;
		FileInputStream fis = null;
		File f = new File(filePath);
		try {
			if (!f.exists() || !f.isFile()) {
				f.createNewFile();
			}
			fis = new FileInputStream(f);
			Properties p = new Properties();
			p.load(fis);
			value = p.getProperty(key, defaultValue);
		} catch (IOException e) {
			Log.e(TAG, e.toString());
		} finally {
			IOUtils.close(fis);
		}
		return value;
	}

	/**
	 * 读取文本数据
	 * 
	 * @param context
	 *            程序上下文
	 * @param fileName
	 *            文件名
	 * @return String, 读取到的文本内容，失败返回null
	 */
	public static String readAssets(Context context, String fileName) {
		InputStream is = null;
		String content = null;
		try {
			is = context.getAssets().open(fileName);
			if (is != null) {

				byte[] buffer = new byte[1024];
				ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
				while (true) {
					int readLength = is.read(buffer);
					if (readLength == -1)
						break;
					arrayOutputStream.write(buffer, 0, readLength);
				}
				is.close();
				arrayOutputStream.close();
				content = new String(arrayOutputStream.toByteArray());

			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
			content = null;
		} finally {
			try {
				if (is != null)
					is.close();
			} catch (IOException ioe) {
				ioe.printStackTrace();
			}
		}
		return content;
	}

	// 生成图片函数
	public static void downloadAndSaveImg(final String imgUrl,
			final String fileURL) {
		new Thread(new Runnable() {

			@Override
			public void run() {
				try {
					// 创建流
					BufferedInputStream in = new BufferedInputStream(new URL(
							imgUrl).openStream());

					// 存放地址
					File img = new File(fileURL);
					// 生成图片
					BufferedOutputStream out = new BufferedOutputStream(
							new FileOutputStream(img));
					byte[] buf = new byte[2048];
					int length = in.read(buf);
					while (length != -1) {
						out.write(buf, 0, length);
						length = in.read(buf);
					}
					in.close();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}).start();
	}

	// 检查连接的有效性
	public static boolean checkURL(String url) {
		Log.d(TAG, "url:" + url);
		boolean value = false;
		try {
			HttpURLConnection conn = (HttpURLConnection) new URL(url)
					.openConnection();
			int code = conn.getResponseCode();
			if (code != 200) {
				value = false;
			} else {
				value = true;
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return value;
	}

	public static void deleteDirExcept(File dir, String fileName) {
		File[] files = dir.listFiles();
		if (files != null && files.length > 0) {
			for (int i = 0; i < files.length; i++) {
				if (files[i].isDirectory()) {
					deleteDirExcept(files[i], fileName);
				} else {
					if (!StringUtil.isEmpty(fileName)) {
						Log.d(TAG, "fileName:" + fileName);
						Log.d(TAG,
								"files[i].getName():" + files[i].getName());
						if (!files[i].getName().equals(fileName)) {
							files[i].delete();
						}
					} else {
						files[i].delete();
					}
				}
			}
		}
	}

	// 将字符串写到文件
	public static void write2File(String content, String path) {
		FileWriter fw = null;
		try {
			File file = new File(path);
			fw = new FileWriter(file, true);

			fw.write(content);

		} catch (IOException e) {

			e.printStackTrace();
		} finally {
			if (fw != null) {
				try {
					fw.close();
				} catch (IOException e) {

					e.printStackTrace();
				}
			}
		}
	}
	/**
	 * 删除所有已上传的图片
	 */
	/*public static void deleteAllPostPhoto(){
		File file = new File(FileUtil.getIconDir());
		if (!StringUtil.isEmpty(ApplicationInfo.getInstance().getUserFilePath())) {
			// TODO 遍历删除
			String fileName = new File(ApplicationInfo.getInstance().getUserFilePath()).getName();
			LogUtil.d(TAG, "fileName:" + fileName);
			FileUtil.deleteDirExcept(file, fileName);
		}
		else {
			// TODO 删除所有
			FileUtil.deleteDirExcept(file, "");
		}
	}*/
}
